<?php

namespace app\api\controller\admin;
use think\Controller;
use app\api\model\User as UserModel;
use app\api\model\DongTai;
use app\api\model\Dianzan;
use app\api\model\ShouChang;
use app\api\model\Address;
use app\api\model\GuanZhu;
use app\api\model\Order;
class User extends Controller {
	public function getAllUser () {
		$page = input('page');
		$user = UserModel::paginate(10,true);
		$data = [];
		foreach ($user as $u) {
			array_push($data,$u);
		}
		$res = [
				'msg' => '获取成功',
				'data' => $data,
				'code' => 200
			];
			
		return json($res);
	}
	public function getCoutUser() {
			$page = input('page');
		$user = UserModel::count('id');
		$res = [
				'msg' => '获取成功',
				'data' => ['count'=>$user],
				'code' => 200
			];
		return json($res);
	}
	public function delUser(){
		$id = input('userId');
		$user = UserModel::get($id);
		$result = $user->delete();
		if($result){
			$res = [
				'code' => 200,
				'msg' => '删除成功'
				];
		    return json($res);
		} else {
			$res = [
				'code' => -1,
				'msg' => '删除失败'
				];
		    return json($res);
		}
	}
	public function index () {
		return 'helloworld';
	}
}